//
//  InformationViewController.m
//  shuiyun
//
//  Created by 马田成 on 2017/9/5.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "InformationViewController.h"
#import "ZJScrollPageView.h"
#import "InformationAnotherViewController.h"

@interface InformationViewController ()<ZJScrollPageViewDelegate>
@property(strong, nonatomic)NSArray<UIViewController<ZJScrollPageViewChildVcDelegate> *> *childVcs;
@property(strong, nonatomic)NSArray<NSString *> *titles;
@end

@implementation InformationViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self creationView];
    [self leftNavHide];
    [self setTitle:@"新闻资讯"];
    
    // Do any additional setup after loading the view.
}
- (void)creationView{

    self.automaticallyAdjustsScrollViewInsets = NO;
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    style.scrollTitle = YES;
    style.autoAdjustTitlesWidth = YES;
    style.adjustCoverOrLineWidth = YES;
    style.selectedTitleColor = [UIColor colorWithRed:63 / 255.0f green:135 / 255.0f blue:246 / 255.0f alpha:1];
    style.scrollLineColor = [UIColor colorWithRed:63 / 255.0f green:135 / 255.0f blue:246 / 255.0f alpha:1];
    style.segmentHeight = 40;
    self.titles = @[@"水运资讯",
                    @"通航信息",
                    @"市场行情",
                    @"海事新闻",
                    ];

    // 初始化
    ZJScrollPageView *scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    [scrollPageView setSelectedIndex:self.indexID animated:YES];
    scrollPageView.contentView.scrollView.scrollEnabled = YES;
    [self.view addSubview:scrollPageView];
    
    // Do any additional setup after loading the view.
}

#pragma mark ----------------ZJScrollPageViewDelegate---------------------
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}
- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    
    InformationAnotherViewController <ZJScrollPageViewChildVcDelegate> *childVc = (InformationAnotherViewController *)reuseViewController;
    
    if (!childVc) {
        
        childVc = [[InformationAnotherViewController alloc] init];
        
        
        childVc.orderStatus = index;
        
        
        NSLog(@"MMMMMMMMMMMMMM%ld", (long)index);
        
        
    }
    
    return childVc;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
